<?php
/**
 * Created by PhpStorm.
 * 抽奖活动
 */
namespace App\frontend\controllers\activity;

use App\common\components\BaseController;
use App\frontend\models\GifBoxLotteryModel;
use App\frontend\services\activity\DrawActivityServices;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class DrawActivityControllers extends BaseController
{
    protected $class_name = 'DrawActivity';

    /**
     * 获取抽奖活动详情
     * $page  int   默认为 0
     * $limit int   默认为 0
     * @desc 获取抽奖活动详情的信息
     */
    public function getDrawActivityDetails(Request $request)
    {
        $data = self::getData($this->class_name,'getDrawActivityDetails');
        if ($data) {
            return $data;
        }
        $validator = Validator::make(
            $request->all(),
            GifBoxLotteryModel::list_rules(),
            GifBoxLotteryModel::message()
        );
        if ($validator->fails()) {
            $msg = $validator->errors()->all();
            return errorJson($msg[0], []);
        }
        $list = DrawActivityServices::getList($data);
        return successJson('获取抽奖活动详情数据成功!', $list);
    }

    /**
     * 获取抽奖活动详情
     * $id       int   默认为 0
     * $integral int   默认为 0
     * @desc 获取抽奖活动详情的信息
     */
    public function getWiningResult(Request $request)
    {
        $data = self::getData($this->class_name,'getWiningResult');
        if ($data) {
            return $data;
        }
        $validator = Validator::make(
            $request->all(),
            GifBoxLotteryModel::list_rules(),
            GifBoxLotteryModel::message()
        );
        if ($validator->fails()) {
            $msg = $validator->errors()->all();
            return errorJson($msg[0], []);
        }
        $list = DrawActivityServices::getList($data);
        return successJson('获取抽奖活动详情数据成功!', $list);
    }

    /**
     * 获取抽奖活动详情
     * $id       int   默认为 0
     * $integral int   默认为 0
     * @desc 获取抽奖活动详情的信息
     */
    public function getDrawRecord(Request $request)
    {
        $data = self::getData($this->class_name,'getDrawRecord');
        if ($data) {
            return $data;
        }
        $validator = Validator::make(
            $request->all(),
            GifBoxLotteryModel::list_rules(),
            GifBoxLotteryModel::message()
        );
        if ($validator->fails()) {
            $msg = $validator->errors()->all();
            return errorJson($msg[0], []);
        }
        $list = DrawActivityServices::getList($data);
        return successJson('获取抽奖活动详情数据成功!', $list);
    }

}
